package com.chenliang.thread.service.impl;

import com.chenliang.thread.service.ThreadPoolExecutorService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CountDownLatch;

/**
 * @program: springboot_thread_002
 * @description:
 * @author: 陈亮
 * @create: 2022-05-15 22:20
 */
@Service
public class ThreadPoolExecutorServiceImpl implements ThreadPoolExecutorService {


    @Override
    @Async("chenLiangPool")
    public void testOne(CountDownLatch countDownLatch) {
        System.out.println("我是:" + Thread.currentThread().getName() + ",我正在执行发送短信任务");
        countDownLatch.countDown();
    }

    @Override
    @Async("chenLiangPool")
    public void testTwo(CountDownLatch countDownLatch) {
        System.out.println("我是:" + Thread.currentThread().getName() + ",我正在执行发送邮件任务");
        countDownLatch.countDown();
    }
}
